package com.hzdl.hotel.controller;

import com.github.pagehelper.PageInfo;
import com.hzdl.hotel.service.LogService;
import com.hzdl.hotel.util.AJAXResult;
import com.hzdl.hotel.vo.LogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/log")
public class LogController {

    @Autowired
    private LogService ls;

    @RequestMapping("/logShowInit")
    public String logShowInit(){
        return "administer/Log";
    }

    @RequestMapping("/logShow")
    @ResponseBody
    public AJAXResult logShow(LogVo logVo){
        if (logVo.getPage() == null) {
            logVo.setPage(1);
        }
        if (logVo.getLimit() == null) {
            logVo.setLimit(5);
        }
        PageInfo pageInfo = ls.findLogByWhere(logVo);
        return new AJAXResult(0, "", pageInfo.getList(), pageInfo.getTotal());
    }
}
